package com.aisino.controller;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aisino.entity.Json;
import com.aisino.entity.LayUIJson;
import com.aisino.mapper.GetDataPageMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * FileName: CheckInDataController.java
 * @Description: 导入数据页面
 * All rights Reserved, Designed By JS-YFB
 * Copyright:   Copyright(C) 2017-2027
 * Company      JS-YFB LTD.
 * @author:     杨陈
 * @version     V1.0 
 * Createdate:  2018年12月11日 下午1:11:43
 */
@RequestMapping("/cgzb")
@Controller
public class CheckInDataController {
	
	@Resource
	private GetDataPageMapper getDataPageMapper;
	
	/**
	 * 获取批次列表形成下啦框
	 * 
	 * @param:   
	 * @return: Json
	 */
	@RequestMapping("/getPCHMList")
	@ResponseBody
	public Json getPCHMList(){
		Json json = new Json(true,"请求批次列表成功",getDataPageMapper.getPCHMList());
		return json;
	}
	
	/**
	 * 通过所选批次号获取单据列表   
	 * where 
	 * 	拆分标识 != 1
	 * 	合并标识 != 1
	 * 	代开发票标识!= 1
	 *  已开发票标识 != 1
	 * 
	 * @param:   
	 * @return: Json
	 */
	@RequestMapping("/getDjhmListByPCHM")
	@ResponseBody
	public LayUIJson getDjhmListByPCHM(@RequestBody Map<String,Object>map){
		PageHelper.startPage((Integer)map.get("page"),(Integer)map.get("limit"));
		List<Map<String,String>> lm = getDataPageMapper.getDjhmListByPCHM(map.get("PCH").toString(),map.get("DJHM").toString());
		PageInfo<Map<String,String>> page = new PageInfo<>(lm);
		LayUIJson layUIJson = new LayUIJson("0", "通过所选批次号获取单据列表成功", page.getTotal(), lm);
		return layUIJson;
	}
	
	/**
	 * 通过单据号号码获取原始明细数据
	 * 
	 * @param:   
	 * @return: Json
	 */
	@RequestMapping("/getInitDataByDJHM")
	@ResponseBody
	public LayUIJson getInitDataByDJHM(@RequestBody Map<String,Object>map){
		PageHelper.startPage((Integer)map.get("page"),(Integer)map.get("limit"));
		List<Map<String,String>> lm = getDataPageMapper.getInitDataByDJHM(map.get("DJHM").toString());
		PageInfo<Map<String,String>> page = new PageInfo<>(lm);
		LayUIJson layUIJson = new LayUIJson("0", "通过单据号号码获取原始明细数据列表成功", page.getTotal(), lm);
		return layUIJson;
	}
	
	@RequestMapping("/ChuShiDataToDaiKaiPiao2")
	@ResponseBody
	public String dd(@RequestBody List<Map<String,String>> lm){
		System.out.println(lm.get(0).get("DJHM"));
		return "123";
	}
}











